package controllers

import (
	"ktvserver/ktvutil"
)

// 修改密码
type ProfileController struct {
	UserController
}

// 修改密码
func (c *ProfileController) Get() {
	c.TplNames = "profile"
	c.Data["title"] = "修改密码"
	c.Data["username"] = DEFAULT_USER
}

// 修改密码
func (c *ProfileController) Post() {
	c.TplNames = "profile"
	c.Data["title"] = "修改密码"

	password := c.GetString("password")
	password2 := c.GetString("password2")

	// 检查是否为空
	if len(password) == 0 || len(password2) == 0 {
		return
	}

	// 检查密码是否一致
	if password != password2 {
		return
	}

	// 保存密码
	ktvutil.SetUserNameAndPasword(DEFAULT_USER, password)

	c.Data["saveok"] = 1

}
